CC		= arm-linux-gcc
LD 		= arm-linux-ld
OBJCOPY	= arm-linux-objcopy
OBJDUMP	= arm-linux-objdump
AR		= arm-linux-ar

NAME		:= lcd
MKHEADER	:=../tools/make_image/mkv210_image

INCDIR		:= $(shell pwd)
CPPFLAGS	:= -nostdlib -nostdinc -I$(INCDIR)/include
CFLAGS		:= -Wall -O2 -fno-builtin

export CC LD OBJCOPY OBJDUMP AR CPPFLAGS CFLAGS

objs := start.o led.o clock.o uart.o lcd.o main.o sdram_init.o
objs += buzzer.o key.o
objs += lib/libc.a

$(NAME).bin: $(objs)
	$(LD) -Tlink.lds -o $(NAME).elf $^
	$(OBJCOPY) -O binary $(NAME).elf $(NAME).bin
	$(OBJDUMP) -D $(NAME).elf > $(NAME)_elf.dis
	@echo make header information for irom booting
	$(MKHEADER) $@
	
################Make LIB#################	
lib/libc.a:
	cd lib; make ; cd ..

###############Make Prj##################
%.o : %.S
	@echo [CC] $<
	@$(CC) -o $@ $< -c $(CPPFLAGS) $(CFLAGS)

%.o : %.c
	@echo [CC] $<
	@$(CC) -o $@ $< -c $(CPPFLAGS) $(CFLAGS)


##############TOOLS#######################
tool:
	make -C ../ tool


#########Clean###########################
clean:
	rm *.o *.elf *.bin *.dis mkx210 *.sdCard -f

clean_lib:
	cd lib; make clean; cd ..

clean_tool:
	make -C ../ clean

.PHONY:tool clean clean_lib clean_tool
